package com.wltjack.common.config;

import com.wltjack.common.MagicCondition;
import com.wltjack.service.impl.MagicServiceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

/**
 * MagicConditionConfig配置类，当Spring容器中存在MagicCondition Bean对象，并满足MagicCondition类的条件时，才去实例化magicService这个Bean。
 */
@Configuration
@ComponentScan(basePackages = {"com.wltjack"})
public class MagicConditionConfig {

    @Bean
    @Conditional(MagicCondition.class) // 指定条件类
    public MagicServiceImpl magicService(){
        return new MagicServiceImpl();
    }

}
